package com.hotel.mapper;

import com.hotel.pojo.Staff;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StaffMapper {
    // 查询所有工作人员信息
    @Select("select * from staff")
    List<Staff> findAllStaff();

    // 新增工作人员
    @Insert("insert into staff(name, username, password, status) values(#{name}, #{username}, #{password}, #{status})")
    void addStaff(Staff staff);

    @Select("select * from staff where name = #{name}")
    Staff findStaffByName(String name);

    @Select("select * from staff where username = #{username}")
    Staff findStaffByUserName(String username);

    // 更新工作人员信息
    @Update("update staff set username=#{username}, password=#{password} where name=#{name}")
    void updateStaff(Staff staff);

    // 删除工作人员
    @Delete("delete from staff where name=#{name}")
    void deleteStaff(Staff staff);

    // 登陆
    @Update("update staff set status=1 where name=#{name}")
    void loginStaff(String name);

    // 注销
    @Update(("update staff set status=0 where name=#{name}"))
    void exitStaff(String name);

    // 查看登录状态
    @Select("select status from staff where name=#{name}")
    int isLogin(String name);
}
